﻿using Assets._Script.Entity;
using Assets._Script.Entity.Character;
using Assets._Script.Entity.Items;
using UnityEngine;

namespace Assets._Script.Controller
{
    public class PlayerController : MonoBehaviour
    {
        //声明要使用的玩家对象
        private Player player;
        //两把用来更换的枪械
        private Gun gun1;
        private Gun gun2;

        // 自定义初始化玩家数据方法
        public void InitPlayer() {
            player = new Player(100, 1);
            //设置沙漠之鹰为玩家的默认武器
            player.Weapon = gun1;
        }

        // Use this for initialization
        void Start()
        {
            //初始化武器数据
            gun1 = new DesertEagle("沙漠之鹰","银色的巨型手枪", 50);
            gun2 = new Ak47("AK47","前苏联制式冲锋枪", 150);
            //初始化玩家数据
            this.InitPlayer();
        }

        // Update is called once per frame
        void Update()
        {
            //数字键1代表沙漠之鹰
            if (Input.GetKeyDown(KeyCode.Alpha1)) {
                    player.ChangeWeapon(gun1);
            }
            //数字键2代表AK47
            if (Input.GetKeyDown(KeyCode.Alpha2))
            {
                player.ChangeWeapon(gun2);
            }
            //鼠标左键开火
            if (Input.GetButtonDown("Fire1")) { 
                player.Shoot();
            }
        }
    }
}